// intercepted.js
(async () => {
  // 从当前脚本的 URL 中提取原始 JS 的路径
  const currentScriptUrl = document.currentScript.src;
  const path = new URL(currentScriptUrl).pathname; // 获取路径部分（如 /intercepted.js）
  const host = window.location.host; // 获取当前页面的域名（如 example.com）
  const originalUrl = `https://${host}${path.replace("/intercepted.js", "")}`; // 构造原始 JS 的 URL

  try {
    // 获取原始 JS 文件内容
    const response = await fetch(currentScriptUrl , {
  "headers": {
    "accept": "*/*",
    "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "sec-ch-ua": "\"Microsoft Edge\";v=\"137\", \"Chromium\";v=\"137\", \"Not/A)Brand\";v=\"24\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "script",
    "sec-fetch-mode": "no-cors",
    "sec-fetch-site": "cross-site",
    "sec-fetch-storage-access": "active",
    "Referer": "https://www.xiaohongshu.com/",
    "Referrer-Policy": "strict-origin-when-cross-origin"
  },
  "body": null,
  "method": "GET"
});
    const content = await response.text();

    // 修改 JS 内容（例如替换某一行）
    const modifiedContent = content.replace(
      `function xhsToken`,
      `window.vvvv=xhsSign;function xhsToken`
    ).replace(
      `function getSigCount`,
      `window.tttt=xsCommon;function getSigCount`
    );

    // 将修改后的内容注入到页面中
    const script = document.createElement("script");
    script.textContent = modifiedContent;
    document.head.appendChild(script);
  } catch (e) {
    console.error("Failed to fetch or modify JS file:", e);
  }
})();